export const schema = {
    type: "page",
    title: "审核列表",
    body: {
        type: "crud",
        api: "/api/team/verify",
        columnsTogglable: false,
        showHeader: false,
        filter: {
            title: "",
            panelClassName: 'no-bg no-border no-shadow no-padder m-b-sm',
            bodyClassName: "no-padder",
            submitText: "",
            controls: [
                {
                    type: "button-group",
                    btnActiveClassName: "btn-info active",
                    value: "0",
                    submitOnChange: true,
                    name: "status",
                    options: [
                        {
                            label: "全部",
                            value: ""
                        },
                        {
                            label: "待审核",
                            value: "0"
                        },
                        {
                            label: "通过",
                            value: "1"
                        },
                        {
                            label: "不通过",
                            value: "2"
                        },
                        {
                            label: "未提交",
                            value: "-1"
                        }
                    ]
                }
            ]
        },
        bulkActions: [
            {
                type: "button",
                label: "通过",
                level: "success",
                actionType: "ajax",
                api: "/api/team/accept/${ids}"
            },

            {
                type: "button",
                label: "不通过",
                level: "danger",
                actionType: "dialog",
                dialog: {
                    title: "批量不通过",
                    body: {
                        type: "form",
                        api: "/api/team/reject/${ids}",
                        controls: [
                            {
                                type: "text",
                                label: "备注",
                                name: "reason"
                            }
                        ]
                    }
                }
            }
        ],
        columns: [
            {
                name: "id",
                label: "团队ID",
                width: 50
            },
            {
                name: "name",
                label: "团队名称",
                type: "tpl",
                tpl: "<a data-link='/team/view/${id}'>${name}</a>"
            },
            {
                name: "org_id",
                label: "所属机构",
                type: "tpl",
                tpl: `<% if (data.acl.can("org:view")) { %>
                        <a data-link='/org/view/<%= data.org.id %>'><%= data.org.name %></a>
                        <% } else { %>
                            <span><%= data.org.name %></span>
                            <% } %>`
            },
            {
                name: "parent_id",
                label: "上级团队",
                type: "tpl",
                tpl: `
                <% if (data.parent_team) { %><a data-link='/team/view/<%= data.parent_id %>'><%= data.parent_team.name %></a><% } else { %><span class='text-muted'>-</span><% } %>
                `
            },
            {
                name: "contact_name",
                label: "联系人"
            },
            {
                name: "contact_phone",
                label: "联系电话"
            },
            {
                label: "地址",
                type: "tpl",
                tpl: "${province_name} ${city_name} ${county_name} ${addr}"
            },

            {
                name: "created_at",
                label: "申请日期"
            },

            {
                label: "状态",
                name: "verify_status",
                type: "map",
                map: {
                    "-1": "<span class='label label-danger'>未提交</span>",
                    "0": "<span class='label label-warning'>待审核</span>",
                    "1": "<span class='label label-success'>已通过</span>",
                    "2": "<span class='label label-default'>已拒绝</span> ${verify_msg}",
                    "*": "${verify_status}"
                }
            }
        ]
    }
};
